package cn.tomas;

import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * @author Mr.Still
 * @version 1.0.0
 * @date 2021-11-10 12:09
 **/
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class TomasApplication {
    public static void main(String[] args) {
        SpringApplication.run(TomasApplication.class,args);
    }

    @Bean("jacksonRabbitTemplate")
    public RabbitTemplate jacksonRabbitTemplate(ConnectionFactory connectionFactory) {
        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
        rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
        return rabbitTemplate;
    }
}
